#pragma once
#include <string>
#include <unordered_map>
#include <vector>
#include <functional>

template <typename T>
class BlockingQueuePro;
class ConnObject;
class SqlOperation;
namespace sql{
    class ResultSet;
}
#include "QueryCallback.h"

class MySqlConnPool
{
    MySqlConnPool(const std::string &db);
    ~MySqlConnPool();
public:
    static MySqlConnPool* GetInstance(const std::string &db);
    void InitConnPool(const std::string &url,int sizepool);
    QueryCallback PushQuery(const std::string &sql, std::function<void(std::unique_ptr<sql::ResultSet>)> &&cb);
private:
    static std::unordered_map<std::string,MySqlConnPool*> m_pools_map;
    std::string m_mysql_db;     //数据库名
    std::vector<ConnObject*> m_vec_conn;
    BlockingQueuePro<SqlOperation*> *m_task_queue;
};


